/**
 * The Free Gaming System; error handling functions.
 *
 * Copyright 2006 the Free Gaming System developers.
 *
 * FGS is the legal property of its developers, whose names are too
 * numerous to list here.  Please refer to the COPYRIGHT file
 * distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

#include <stdlib.h>
#include <string.h>
#include "fgs_game.h"
#include "fgs_internal.h"

static char *error_str[] = {
  "No error",
  "Unknown error",
  "Invalid parameters",
  "Invalid network engine type",
  "Invalid callbacks table",
  "Invalid FGS context",
  "Invalid player UUID",
  "Invalid match UUID",
  "Reply line from peer too long",
  "Malformed peer reply",
  "Invalid magic received from client",
  "Client not using protocol version " FGS_CLIENT_PROTO_VER_STR,
  "Socket-level error during communication",
  "Connection reset by peer",
  "Error during player/match registration",
  "Error during the configuration process",
  "Game server shutdown requested",
  "Player is not authorized to join game",
  "Match creation not authorized",
  "FGS proxy is unreachable",
  "Error during player unregistration",
  "Error during match unregistration",
  "Error during metadata update",
  "Internal error"
};

char *fgs_strerror(fgs_error_t err_code)
{
  char *errstr = fgs__alloc(strlen(error_str[err_code])+1, sizeof(*errstr));

  strcpy(errstr, error_str[err_code]);

  return errstr;
}
